import axios from "axios";
import { message } from 'ant-design-vue'
const instance = axios.create({
    timeout: 10 * 1000,
})
instance.interceptors.request.use(
    config => {
        // config.headers['Authorization'] = `Bearer ${getToken()}` // JWT 的固定格式
        return config
    },
    error => Promise.reject(error)
)
instance.interceptors.response.use(res => {
    const resData = (res.data || {})
    const { errno, data, msg } = resData
    if (errno !== 0) {
        // 错误提示
        if (msg) {
            message.error(msg)
        }

        throw new Error(msg)
    }
    return data
})
export default instance
